<?php
namespace app\common\model\signreport;

use think\Model;

class Sign extends Model
{
    protected $table = 'signs';
    protected $pk    = 'Id';

    public function getSignTimeAttr($value)
    {
        return Date('Y-m-d H:i:s', $value);
    }

    // 获取签到列表
    public function getList($where) {

        $data = $this->where($where)->order('SignTime desc')->select();
        return $data;
    }
    public function doSign($params) {
        $t = time();
        $this->UId = $params['UId'];
        $this->SignTime = $t;
        $this->SignDate = strtotime(date('Y-m-d', $t));
        $this->SignImg = isset($params['SignImg'])?$params['SignImg']: '';
        $this->Lat = isset($params['Lat'])?$params['Lat']: '';
        $this->Lon = isset($params['Lon'])?$params['Lon']: '';
        $this->Address = isset($params['Address'])?$params['Address']: '';
        $this->Distance = isset($params['Distance'])?$params['Distance']: '';
        $this->save();
        $rst = [
            'Id' => $this->Id,
        ];
        return $rst;
    }
}
